/*
 * @Author: ycg520520
 * @Date: 2025-02-24 18:14:01
 * @LastEditTime: 2025-07-10 00:42:48
 * @LastEditors: colpu ycg520520@qq.com
 * @Description:
 */
import { resolve } from "path";
import vitePluginDynamicImport from "vite-plugin-dynamic-import";

import { defineConfig as _defineConfig } from "vite";
import react from "@vitejs/plugin-react-swc";
import { viteMockServe } from "vite-plugin-mock";
import { createStyleImportPlugin } from "vite-plugin-style-import";
const PROCESS_CWD = process.cwd(); // 进程启动位置
export const defineConfig = (option = Object.create(null)) => {
  return _defineConfig({
    resolve: {
      alias: {
        "@": resolve(PROCESS_CWD, "./src"),
      },
    },
    css: {
      preprocessorOptions: {
        less: {
          javascriptEnabled: true,
        },
      },
    },
    ...option,
    plugins: [
      react(),
      viteMockServe(),
      vitePluginDynamicImport({
        // options
      }),
      createStyleImportPlugin({
        libs: [
          {
            libraryName: "antd",
            esModule: true,
            resolveStyle: (name: string) => `antd/es/${name}/style`,
          },
        ],
      }),
    ],
  });
};
